package com.m3839.sdk.common.ui;

import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.m3839.sdk.common.base.BaseDialogFragment;
import com.m3839.sdk.common.core.Constant;
import com.m3839.sdk.common.core.SdkConfiguration;
import com.m3839.sdk.common.util.AppUtils;


/**
 * @author ChenBaoyang
 * @description: TipDialogFragment，通用的全局断网或者接口异常弹窗
 * @date 5/12/21 09:41
 */
public class NetTipDialogFragment extends BaseDialogFragment {

    private TextView policyTv;
    private TextView tipTv;
    private Button negativeBtn;

    public static NetTipDialogFragment newInstance() {
        NetTipDialogFragment fragment = new NetTipDialogFragment();
        return fragment;
    }

    @Override
    protected void parseArgs() {

    }

    @Override
    protected String getLayoutName() {
        return "common_tip";
    }

    @Override
    protected void initView(View view) {
        policyTv = view.findViewById(getId("tv_public_policy"));
        tipTv = view.findViewById(getId("tv_warm_tip"));
        negativeBtn = view.findViewById(getId("dlg_btn_negative"));
    }

    @Override
    protected void setContent() {
        policyTv.setText(SdkConfiguration.getNetErrorContent());
        tipTv.setText(SdkConfiguration.getNetErrorTips());
        negativeBtn.setText(Constant.NET_ERROR_DIALOG_BTN_TXT);
    }

    @Override
    protected void initListener() {
        negativeBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
                AppUtils.killAllProcess(getActivity());
            }
        });
    }

}
